package org.example.service;

import java.util.Scanner;

public class Work1 {
    /**
     * 输入一个字符串"abafeabdfaababdrera”中有多少个连续的"ab”
     */

    /**
     * 方法一
     *
     * @return 连续"ab"的个数
     */
    public int count() {
        System.out.println("输入一个字符串判断有多少个连续的'ab'");
        Scanner sc = new Scanner(System.in);
        String string = sc.next();
        return (string.length() - string.replaceAll("ab", "").length()) / 2;
    }


    public static void main(String[] args) {
        Work1 work1 = new Work1();
        System.out.println(work1.count());
    }
}
